<?php
namespace app\site\model;

use app\common\library\Model;
use think\model\concern\SoftDelete;
class SiteOperate extends Model
{
	/**
	 * [feeLogInfo description]
	 * @return [type] [description]
	 */
    protected function feeLogInfo(){
		return $this->hasOne("app\\custom\\model\\CustomFee",'id', 'log_id');
	}
	/**
	 * [customInfo description]
	 * @return [type] [description]
	 */
	protected function customInfo(){
		return $this->hasOne("app\\custom\\model\\Custom",'current_id','custom_id')->field('current_id,nickname,username,avatar,last_login_time');
	}
	/**
	 * [siteInfo description]
	 * @return [type] [description]
	 */
	protected function siteInfo(){
		return $this->hasOne("app\\site\\model\\Site",'id','site_id');
	}
	/**
	 * [getActionTextAttr description]
	 * @param  [type] $value [description]
	 * @param  [type] $data  [description]
	 * @return [type]        [description]
	 */
	protected function getActionTextAttr($value,$data){
		if(empty($data['action'])) return '';
		switch ($data['action']) {
			case 'create':
				return '开通站点';
				break;
			case 'renew':
				return '续费';
				break;
			default:
				break;
		}
	}
	/**
	 * [getNumberTextAttr description]
	 * @param  [type] $value [description]
	 * @param  [type] $data  [description]
	 * @return [type]        [description]
	 */
	protected function getNumberTextAttr($value,$data){
		if(empty($data['unit'])) return '';
		switch ($data['unit']) {
			case 'month':
				return $data['number'].'月';
				break;
			case 'quarter':
				return $data['number'].'季';
				break;
			case 'year':
				return $data['number'].'年';
				break;
			case 'forever':
				return '永久';
				break;
			default:
				# code...
				break;
		}
	}
}